package com.sky.web.admin;

import com.sky.result.Result;
//import jdk.jpackage.internal.Log;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/admin/shop")
public class ShopController {

    @Autowired
    private RedisTemplate redisTemplate;

    // 修改店铺状态
    @PutMapping("/{status}")
    public Result changeShopStatus(@PathVariable("status") Integer status) {
        log.info("修改店铺状态:{}", status);
        redisTemplate.opsForValue().set("SHOP_STATUS", status);
        return Result.success();
    }

    // 查询店铺状态
    @GetMapping("/status")
    public Result getShopStatus() {

        log.info("查询店铺状态");
        //Integer status = (Integer) redisTemplate.opsForValue().get("SHOP_STATUS");
        //return Result.success(status);
        return Result.success( redisTemplate.opsForValue().get("SHOP_STATUS"));
    }
}